import request from '@/utils/request.js'

export const getEmployeesSimpleList = () => {
  return request({
    url: '/sys/user/simple'
  })
}

/**
 * 获取员工列表
 * @param {*} params
 * @returns
 */
export const getEmployeesList = (params) => {
  return request({
    url: '/sys/user',
    params
  })
}

/**
 * 添加员工
 * @param {*} params
 * @returns
 */
export const addEmployees = (data) => {
  return request({
    url: '/sys/user',
    method: 'POST',
    data
  })
}

/**
 * 删除员工
 * @param {*} params
 */
export const deleteEmployees = (id) => {
  return request({
    url: '/sys/user/' + id,
    method: 'DELETE'
  })
}

/** *
 *  封装一个导入员工的接口
 *
 * ***/

export function importEmployee(data) {
  return request({
    url: '/sys/user/batch',
    method: 'post',
    data
  })
}

/** *
 *  封装一个导入员工的接口
 *
 * ***/

export function updateEmployee(data) {
  return request({
    url: '/sys/user/' + data.id,
    method: 'PUT',
    data
  })
}

/**
 * 获取员工详细信息
 * @param {*} id String
 */
export function getEmployeesDetail(id) {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}

/**
 * 更新员工详细信息
 * @param {*} data {}
 */
export function updateEmployeesDetail(data) {
  return request({
    url: `/employees/${data.id}/personalInfo`,
    method: 'PUT',
    data
  })
}

/**
 * 获取员工岗位信息
 * @param {*} id 员工id
 */
export function getEmployeesJobInfo(id) {
  return request({
    url: `/employees/${id}/jobs`,
    method: 'GET'
  })
}

/**
 * 更新员工岗位信息
 * @param {*} data {}
 */
export function updateEmployeesJobInfo(data) {
  return request({
    url: `/employees/${data.id}/jobs`,
    method: 'PUT',
    data
  })
}

/**
 * 给员工分配角色
 * @param {*} data {}
 */
export function updateEmployeesRoles(data) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'PUT',
    data
  })
}
